package ru.linnenson.darshana.infrastructure.rest.mappers;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import ru.linnenson.darshana.infrastructure.persistence.models.MathTaskStore;
import ru.linnenson.darshana.infrastructure.rest.dto.MathTaskResponse;
import java.util.List;

@Mapper(componentModel = "spring")
public interface MathTasksMapper {

  @Mapping(target = "withSolution", source = "solutionPhotoIds", qualifiedByName = "getWithSolution")
  MathTaskResponse toDto(MathTaskStore task);

  List<MathTaskResponse> toDto(List<MathTaskStore> tasks);

  @Named("getWithSolution")
  static boolean getWithSolution(List<String> solutionPhotoIds) {
    return solutionPhotoIds != null && !solutionPhotoIds.isEmpty();
  }
}
